package com.zwd.cases.demo.gof23.component.demo1;

/**
 * @Description Decorator, 装饰抽象类继承了Component,从外类来扩展Component类的功能，但对于Component来说，是无需知逾ecorator的存在的
 * @Author zhengwd
 * @Date 2023/4/18 23:55
 **/
abstract class Decorator extends Component {

    protected Component component;

    /**
     * 设置Component
     * @param component
     */
    public void setComponet(Component component) {
        this.component = component;
    }

    /**
     * 重写OperationO,实际执行的是Component Operation()
     */
    @Override
    public void operation() {
        if (component != null) {
            component.operation();
        }
    }
}
